const ol = require('openlayers');
require('openlayers/dist/ol.css');

const tian_di_tu_bgmap = new ol.layer.Tile({
  source: new ol.source.XYZ({
    crossOrigin:'anonymous',
    url: "http://t4.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}"
  }),

});
const tian_di_tu_annotation = new ol.layer.Tile({
  title: "天地图文字标注",
  source: new ol.source.XYZ({
    crossOrigin:'anonymous',
    url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}'
  }),

});
const tian_di_tu_satellite_layer = new ol.layer.Tile({
  title: "天地图卫星影像",
  source: new ol.source.XYZ({
    crossOrigin:'anonymous',
    url: 'http://t3.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}'
  }),
});
// 鼠标左下角显示
const mousePositionControl = new ol.control.MousePosition({
  coordinateFormat: ol.coordinate.createStringXY(4),
  projection: 'EPSG:4326',
  className: 'custom-mouse-position',
  target: document.getElementById('mouse-position'),
  undefinedHTML: '&nbsp;'
});

const OSMtile = new ol.layer.Tile({
  source: new ol.source.OSM()
});
const qqTile = new ol.layer.Tile({
  source: new ol.source.XYZ({
    crossOrigin:'anonymous',
    url: 'http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}'
  }),
});
// source
const source = new ol.source.Vector({wrapX: false});
//绘图绘在此矢量图层
const vector = new ol.layer.Vector({
  source: source,
  style: new ol.style.Style({ //修改绘制的样式
    fill: new ol.style.Fill({
      color: 'rgba(255, 255, 255, 0.2)'
    }),
    stroke: new ol.style.Stroke({
      color: '#ffcc33',
      width: 2
    }),
    image: new ol.style.Circle({
      radius: 7,
      fill: new ol.style.Fill({
        color: '#ffcc33'
      })
    })
  })
});


const pointData = [
  {
    "id": 1,
    "name": "P1",
    "x": 1,
    "y": 1,
    "z": 1,
    "image": ""
  }, {
    "id": 2,
    "name": "P2",
    "x": 2,
    "y": 2,
    "z": 2,
    "image": ""
  },

];

const lineData = [
  {
    "id": 1,
    "name": "p1-p2",
    "qdx": 1,
    "qdy": 1,
    "zdx": 2,
    "zdy": 2,
    "image": ""
  }, {
    "id": 2,
    "name": "p2-p3",
    "qdx": 1,
    "qdy": 1,
    "zdx": 2,
    "zdy": 2,
    "image": ""
  },

];



export {
  pointData, lineData, tian_di_tu_bgmap,
  tian_di_tu_annotation,
  tian_di_tu_satellite_layer, mousePositionControl,
  vector
};
